package com.zqz.smp.springboot_mybatis_plus.controller;


import com.zqz.smp.springboot_mybatis_plus.bean.Result;
import com.zqz.smp.springboot_mybatis_plus.bean.User;
import com.zqz.smp.springboot_mybatis_plus.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/User")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/Search")
    public Result Search(){
        Result result = new Result();
        List<User> search = userService.search();
        if (search.isEmpty()){
            return new Result("404","没有该关键字的数据",null);
        }else {
            result.setMessage("搜索成功");
            result.setCode("200");
            result.setData(search);
        }
        return result;
    }

}
